package com.baidu.process.imchat.web;

import com.baidu.process.chat.core.web.bean.IMRequestServer;
import com.baidu.process.imchat.entity.ImResult;
import com.baidu.process.imchat.service.impl.ImChatServiceImpl;
import com.baidu.process.record.bean.DialogueRecord;
import com.baidu.process.record.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @Author:fangyuchao
 * @Description:
 * @Date: Create in 16:41 2022/11/10
 */
@RestController
public class TestImChat {
    @Autowired
    private ImChatServiceImpl imChatService;
    @Autowired
    private RecordService recordService;
    @RequestMapping("imtest")
    public ImResult testIm(@RequestBody IMRequestServer imRequestServer){

        List<Map<String,Object>> msgBody = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("msgType","TIMTextElem");
        Map<String,String> textMap = new HashMap<>();
        textMap.put("text","baidutest");
        map.put("msgContent",textMap);
        msgBody.add(map);
        return imChatService.imChat(imRequestServer,msgBody);
    }

    @RequestMapping("sqltest")
    public List<DialogueRecord> sqltest(){
        return recordService.selectAll();
    }

//    @RequestMapping("savetest")
//    public DialogueRecord savetest(@RequestBody DialogueRecord dialogueRecord){
//
//         recordService.saveAsyncRecord(DialogueRecord dialogueRecord,IMRequestServer imRequestServer,String ngdResJson);
//
//            return  dialogueRecord;
//    }









}
